package es.cazadoresmadridejos.beans.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import es.cazadoresmadridejos.beans.service.mail.MailService;
import es.cazadoresmadridejos.util.constants.Constants;

@Controller
public class ErrorController {
	
	@Autowired private MailService mailService;	

	@RequestMapping("/500.html")
	public ModelAndView error(
			HttpServletRequest request, HttpServletResponse response
			){
		mailService.sendMail("cazadores.madridejos@gmail.com", "ERROR", "Ha habido un error a las: " + Constants.sdfTime.format(new Date()));
		return new ModelAndView();
	}
}
